<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<div class="col-md-12">
	<div class="panel-search">
		<form class="form-inline" action="/account/list">
			<div class="form-group">
				<label class="control-label">请选择渠道：</label><select
					class="form-control" name="platformValue" style="width: 200px;">
					<option value="0">全部</option>
					<c:forEach items="${platforms}" var="platform" varStatus="vs">
						<option value="${platform.id }">${platform.name }</option>
					</c:forEach>
				</select>

			</div>
		</form>
		<div class="btn-div">
			<div class="div-left">
				<label style="margin-left: 20px;">状态：</label><span
					class="depressed active">全部</span><span class="depressed">启用</span><span
					class="depressed">停用</span>
			</div>
			<div class="div-right">
				<button type="button" class="btn btn-primary"
					onclick="searchAccount()">
					<i class="fa fa-search"></i>
					<spring:message code="btn.search"></spring:message>
				</button>
				<button class="btn btn-primary" onclick="add('/account/account')">
					<i class="fa fa-plus"></i>新建账号
				</button>
			</div>
		</div>
	</div>
	<div class="panel-content"></div>
</div>
<style type="text/css">
.div-left label {
	font-size: 16px;
}

.div-left span {
	margin-left: 20px;
	font-size: 16px;
}

.div-left span.active {
	background-color: #4F94CD;
	color: #ffffff;
	border-radius: 5px;
}
</style>
<script type="text/javascript"
	src="<c:url value="/static/custom/datepicker-util.js"></c:url>"></script>
<script type="text/javascript">
	var activeClass = $('.depressed.active');
	$(function() {
		search();
		$(".div-left span").click(function() {
			if (activeClass != null) {
				activeClass.removeClass('active');
			}
			$(this).addClass('active');
			activeClass = $(this);
		})
	});

	function addModel() {
		$('#menuModal').modal('show');
	}

	//查询账户
	function searchAccount() {
		var platformId = $('select option:selected').val();
		var status = $('.depressed.active').html();
		console.log(platformId + " : " + status);
		
		if (platformId == 0) {
			platformId = null;
		}
		/* 加载动画 */

		$.when($.ajax({
			type : 'post',
			url : webRoot + "/account/list",
			data : {
				platformId : platformId,
				username : status
			},
			dataType : 'html'
		})).done(function(data) {
			/* 结束加载动画 */

			$(".panel-content").html(data);
		})
	}
</script>